<?php
require_once("./config.php");
require_once("./smarty_config.php");
require_once("./phpmailer/class.phpmailer.php");
$mail = new PHPMailer(true);

$files = glob('./classes/*.php');
foreach ($files as $file) {
    require_once($file);   
}
$system = new System();
$users = new Users();

$logged=false;
if(isset($_COOKIE['cookie_user']) && isset($_COOKIE['cookie_hashcode'])){
	if(count($sql->QueryGetFetch("SELECT * FROM `uzytkownicy` WHERE `login`='".$_COOKIE['cookie_user']."' AND `hash_code`='".($_COOKIE['cookie_hashcode'])."'"))){
		$logged = true;
		$k = $sql->QueryGetFetch("SELECT * FROM `uzytkownicy` WHERE `login`='".$_COOKIE['cookie_user']."' AND `hash_code`='".($_COOKIE['cookie_hashcode'])."'");
		$logged_user_id = $k[0]['id']; 
		$logged_user_name = $k[0]['login'];
		$smarty->assign("logged_user_name",$logged_user_name);
	}
}

define("LOGGED",$logged);
$smarty->assign('system',$system);
$smarty->assign("host",$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']));
$smarty->assign("_LOGGED",$logged);
//$quiz->openTxt("./quiz.txt");
?>